﻿@model IEnumerable<Ecommerce.Areas.Manager.Models.Category>
@{
    ViewBag.Title = "Category Manager";
}
<p>
    @Html.ActionLink("Add new category", "Regist")
</p>
<fieldset>
    <legend>Categories List</legend>
    <p class="field-validation-error">
        @ViewBag.ErrorMsg
    </p>
    <table border="0">
        <thead>
            <tr>
                <td>Category Name</td>
                <td>Number of products</td>
                <td>Sort order</td>
                <td>Action</td>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model)
            {
                <tr>
                    <td>@Html.DisplayFor(modelItem => item.CategoryName)</td>
                    <td>@Html.DisplayFor(modelItem => item.Products)</td>
                    <td>@Html.DisplayFor(modelItem => item.Order)</td>
                    <td>
                        @Html.ActionLink("Edit", "Edit", new { id = item.CategoryID })
                        &nbsp;
                            @Html.ActionLink("Delete", "Delete", new { id = item.CategoryID }, new { @class = "delLink" })
                    </td>
                </tr>
            }
        </tbody>
    </table>
</fieldset>

<script type="text/ecmascript">
    $(".delLink").click(function () {

        return (confirm("Are you sure want to delete this category?"));
    });
</script>
